<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%mp_users}}".
 *
 * @property int $id
 * @property int|null $bind_user_id 绑定的用户
 * @property string $mp_openid
 * @property string $mp_appid
 * @property string|null $unionid
 * @property string|null $pa_openid 公众号openid
 * @property string|null $nickname
 * @property string|null $avatar 微信头像
 * @property string|null $mobile
 * @property int $gender
 * @property int $status 1:正常
 * @property string $token
 * @property string $key
 * @property int $created_at
 * @property int $updated_at
 */
class MpUsers extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%mp_users}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['bind_user_id', 'mp_openid', 'mp_appid', 'unionid', 'pa_openid', 'nickname', 'avatar', 'mobile', 'gender', 'status', 'token', 'key', 'created_at', 'updated_at'], 'trim'],
            [['bind_user_id', 'gender', 'status', 'created_at', 'updated_at'], 'integer'],
            [['mp_openid', 'mp_appid', 'token', 'key', 'created_at', 'updated_at'], 'required'],
            [['mp_openid', 'mp_appid', 'unionid', 'pa_openid', 'nickname', 'avatar'], 'string', 'max' => 180],
            [['mobile'], 'string', 'max' => 11],
            [['token', 'key'], 'string', 'max' => 32],
            [['bind_user_id', 'unionid', 'pa_openid', 'nickname', 'avatar', 'mobile'], 'default', 'value' => null],
            [['gender'], 'default', 'value' => 0],
            [['status'], 'default', 'value' => 1],
            [['token'], 'unique'],
            [['mp_openid', 'mp_appid'], 'unique', 'targetAttribute' => ['mp_openid', 'mp_appid']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'bind_user_id' => Yii::t('app', '绑定的用户'),
            'mp_openid' => Yii::t('app', 'Mp Openid'),
            'mp_appid' => Yii::t('app', 'Mp Appid'),
            'unionid' => Yii::t('app', 'Unionid'),
            'pa_openid' => Yii::t('app', '公众号openid'),
            'nickname' => Yii::t('app', 'Nickname'),
            'avatar' => Yii::t('app', '微信头像'),
            'mobile' => Yii::t('app', 'Mobile'),
            'gender' => Yii::t('app', 'Gender'),
            'status' => Yii::t('app', '1:正常'),
            'token' => Yii::t('app', 'Token'),
            'key' => Yii::t('app', 'Key'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
        ];
    }
}
